# -*- coding: utf-8 -*-
import json

from devicetest.api import Asserts
from devicetest.log.logger import print_info
from devicetest.aw.OpenHarmony import CommonOH, BluetoothHelper
from devicetest.core.test_case import TestCase, Step

from aw.common import common_setup, common_teardown
from aw.pom import ControlCenter, Setting


class PreTest_RK3568_Basic_Systemui_1000(TestCase, ControlCenter):
    # 预置条件：
    # 烧写目标版本后，正常进入桌面
    # 测试步骤：
    # 进入桌面，右上角下划进入控制中心，点击控制中心响铃按钮
    # 预期结果：
    # 点击或重复点击有效，与设置响铃按钮同步变化，静音状态时最上侧有静音标识，无异常

    def __init__(self, controllers):
        self.TAG = self.__class__.__name__
        TestCase.__init__(self, self.TAG, controllers)

    def setup(self):
        common_setup(self.Phone1)

    def process(self):
        Step('步骤1、进入桌面，右上角下划进入控制中心，点击控制中心响铃按钮')
        CommonOH.startAbility(self.Phone1, Setting.ability_name, Setting.bundle_name)
        CommonOH.wait(self.Phone1, 1)
        CommonOH.touchByText(self.Phone1, '声音')
        status0 = json.loads(CommonOH.getWidgetProperties(self.Phone1, condition='type/Radio')).get('checked')
        CommonOH.swipe(self.Phone1, **self.pull_down)
        CommonOH.wait(self.Phone1, 1)
        CommonOH.click(self.Phone1, **self.sound_switch)
        CommonOH.wait(self.Phone1, 2)
        Step('预期结果1、点击或重复点击有效，与设置响铃按钮同步变化，静音状态时最上侧有静音标识，无异常')
        CommonOH.swipe(self.Phone1, **self.pull_up)
        CommonOH.wait(self.Phone1, 1)
        status1 = json.loads(CommonOH.getWidgetProperties(self.Phone1, condition='type/Radio')).get('checked')
        Asserts.assert_not_equal(status0, status1)

    def teardown(self):
        common_teardown(self.Phone1, Setting.bundle_name)
        CommonOH.swipe(self.Phone1, **self.pull_up)
